<template>
  <div>
    <el-row class="tac">
      <el-col :span="4">
        <el-menu
            :unique-opened="true"
            :default-active="$route.path"
            @select="handleSelect"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose">
          <template>
            <span>
              <h2 style="margin-left: 40px;margin-bottom: 10px;margin-top: 20px;color: #303133">成绩管理系统</h2>
            </span>
          </template>
          <el-menu-item>
            <span style="margin-left: 6px;font-weight: bold;color: #303133"><img src="@/assets/imgs/用户.png"
                                                                  style="margin-top: -15px;"
                                                                  width="18%"/> 用 户：{{ userName }}</span>
          </el-menu-item>
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>信息管理</span>
            </template>
            <el-menu-item-group>
              <el-menu-item :index="item.grades">
                <i class="el-icon-s-order"></i>
                成绩管理
              </el-menu-item>
              <el-menu-item :index="item.student">
                <i class="el-icon-user"></i>
                学生管理
              </el-menu-item>
              <el-menu-item :index="item.SubjectPage">
                <i class="el-icon-date"></i>
                课程管理
              </el-menu-item>
              <el-menu-item :index="item.TeacherPage">
                <i class="el-icon-s-custom"></i>
                教师管理
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-menu-item :index="item.InformationManage">
            <i class="el-icon-menu"></i>
            <span slot="title">功能应用</span>
          </el-menu-item>
          <el-menu-item :index="item.loginSettings">
            <i class="el-icon-setting"></i>
            <span slot="title">登录设置</span>
          </el-menu-item>
        </el-menu>
      </el-col>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-row>

  </div>
</template>

<script>
export default {
  name: "NavigationBar",
  data() {
    return {
      isCollapse: true,
      userName: '',
      item: {
        grades: "/NavigationBar/GradesQuery",
        student: "/NavigationBar/StudentPage",
        loginSettings: "/NavigationBar/LoginSettings",
        InformationManage: "/NavigationBar/InformationManage",
        SubjectPage:"/NavigationBar/SubjectPage",
        TeacherPage:"/NavigationBar/TeacherPage"
      },
    };

  },
  mounted: function () {
    this.user();
  },
  methods: {
    user() {
      this.userName = this.$route.query.userName;
      // console.log(this.userName)
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    handleSelect(path) {
      this.$router.push({path, query: {userName: this.userName}});
    },
  }
}

</script>

<style scoped>
.div{
  background-color: lavender;
}
</style>